package com.kyecloud.common.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * 主要功能：分页查询
 * @param <T>
 */
public class PageQuery<T> implements Serializable {
	private static final long serialVersionUID = 1L;
	//查询的页数
	private int pageNum = 1;
	//每页显示多少行
    private int pageSize = 10;
    //总行数
    private int total;
    //返回的结果集
    private List<T> rows = new ArrayList<T>();
	//总页数
	private int totalPage;
    
    public PageQuery() {
		
	}
    
	public PageQuery(int pageNum, int pageSize) {
		this.pageNum = pageNum;
		this.pageSize = pageSize;
	}
	
	public PageQuery(int pageNum, int pageSize,int total,List<T> rowsList) {
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.total = total;
		this.rows = rowsList;
	}
	
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public List<T> getRows() {
		return rows==null?new ArrayList<T>():rows;
	}
	public void setRows(List<T> rows) {
		this.rows = rows;
	}
	public int getPageCount() {
		return (int)Math.ceil(((double)this.total/this.pageSize));
	}
	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int pTotalPage) {
		totalPage = pTotalPage;
	}
	
}
